using UnityEngine;
using System.Collections;

public class TrashObject : MonoBehaviour {

	
	private void HandlePosition(Vector3 position)
	{
		Ray ray = Camera.main.ScreenPointToRay(position);
		
		RaycastHit hit;
		
		if(Physics.Raycast(ray.origin, ray.direction, out hit))
		{
			GameObject hitObject = hit.collider.gameObject;
				//Debug.Log("touch");
			
			if(hitObject.tag == "Trash"){
				
				Debug.Log("touch trash object");
				Highlight();
			}
		}
	}
	
	private void HandleTouch()
	{
		if(Input.touchCount == 1)
		{
			Touch touch = Input.touches[0];
			HandlePosition(touch.position);
		}
	}
	
	private void HandleMouse()
	{
		if(Input.GetMouseButtonUp(0))
		{
			HandlePosition(Input.mousePosition);
		}
	}
	
	private void Highlight()
	{
		
	}
	
	// Update is called once per frame
	void Update () {
		
		if(Application.platform == RuntimePlatform.Android)
		{
			HandleTouch();
		}
		else
			HandleMouse();
	}
}
